<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\Template;

class DeleteUnavailableTemplate extends Command {
    
    protected $signature = 'dut';
    protected $description = '删除不可用的模板';
    
    public function __construct() {
        parent::__construct ();
    }
    
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function handle() {
        $this->error('开始删除不可用的模板信息');
        $templates = Template::where('name', 'not like', '%{name}%')->select('id')->get();
        $c = count($templates);
        $i = 0;
        foreach ($templates as $t) {
            $t->delete();
            $i++;
            $this->info($i.'/'.$c);
        }
    }
}
